//package com.gk.springauth2order.config.local;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.http.SessionCreationPolicy;
//import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
//import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
//import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
//import org.springframework.security.oauth2.provider.token.RemoteTokenServices;
//import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
//
///**
// * @Author poison
// * @Date 2020/10/14 11:26
// */
//@Configuration
//@EnableResourceServer
////@EnableGlobalMethodSecurity(securedEnabled = true,prePostEnabled = true)
//public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
//
//    // 配置资源服务的id
//    public static String RESOURCE_ID = "res1";
//
//    //@Autowired
//    //private TokenStore tokenStore;
//
//    @Override
//    public void configure(ResourceServerSecurityConfigurer resources) {
//        resources.resourceId(RESOURCE_ID)//资源 id
//                //.tokenStore(tokenStore)
//                // 验证令牌的服务
//                .tokenServices(tokenService())
//                .stateless(true);
//    }
//
//        //资源服务令牌解析服务
//    @Bean
//    public ResourceServerTokenServices tokenService() {
//        //使用远程服务请求授权服务器校验token,必须指定校验token 的url、client_id，client_secret
//        RemoteTokenServices service=new RemoteTokenServices();
//        service.setCheckTokenEndpointUrl("http://localhost:8083/auth/oauth/check_token");
//        service.setClientId("client");
//        service.setClientSecret("secret");
//        return service;
//    }
//
//
//    /**
//     * 安全访问策略
//     */
//    @Override
//    public void configure(HttpSecurity http) throws Exception {
//        http
//                .authorizeRequests()
//                // 令牌访问资源的范围
//                .antMatchers("/r/*").access("#oauth2.hasScope('all')")
//                .antMatchers("/a/*").permitAll()
//                //.anyRequest().authenticated()
//                .and().csrf().disable()
//                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
//    }
//
//}
